// $ANTLR 3.3 Nov 30, 2010 12:45:30 D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g 2013-09-13 02:37:13

	package org.moflon.moca.blip.unparser.android;


import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

import org.antlr.stringtemplate.*;
import org.antlr.stringtemplate.language.*;
import java.util.HashMap;
public class PropertiesTreeGrammar extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "ID", "STRING", "ATTRIBUTE", "'Properties'"
    };
    public static final int EOF=-1;
    public static final int T__7=7;
    public static final int ID=4;
    public static final int STRING=5;
    public static final int ATTRIBUTE=6;

    // delegates
    // delegators


        public PropertiesTreeGrammar(TreeNodeStream input) {
            this(input, new RecognizerSharedState());
        }
        public PropertiesTreeGrammar(TreeNodeStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected StringTemplateGroup templateLib =
      new StringTemplateGroup("PropertiesTreeGrammarTemplates", AngleBracketTemplateLexer.class);

    public void setTemplateLib(StringTemplateGroup templateLib) {
      this.templateLib = templateLib;
    }
    public StringTemplateGroup getTemplateLib() {
      return templateLib;
    }
    /** allows convenient multi-value initialization:
     *  "new STAttrMap().put(...).put(...)"
     */
    public static class STAttrMap extends HashMap {
      public STAttrMap put(String attrName, Object value) {
        super.put(attrName, value);
        return this;
      }
      public STAttrMap put(String attrName, int value) {
        super.put(attrName, new Integer(value));
        return this;
      }
    }

    public String[] getTokenNames() { return PropertiesTreeGrammar.tokenNames; }
    public String getGrammarFileName() { return "D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g"; }


    	public Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow)	throws RecognitionException  {
    		try {
            		return super.recoverFromMismatchedToken(input, ttype, follow);
                } catch(java.util.NoSuchElementException e){
                    throw new IllegalArgumentException("Your tree does not comply with your tree grammar!\n"
                    		+ " Problems encountered at: [" + "..." + getTreeNodeStream().LT(-1) + " " 
                    		+ getTreeNodeStream().LT(1) + "..." + "] in tree.");
    		}
        }


    public static class main_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "main"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:34:1: main : ^( 'Properties' (attrs+= attr )* ) -> main(attrs=$attrs);
    public final PropertiesTreeGrammar.main_return main() throws RecognitionException {
        PropertiesTreeGrammar.main_return retval = new PropertiesTreeGrammar.main_return();
        retval.start = input.LT(1);

        List list_attrs=null;
        RuleReturnScope attrs = null;
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:34:5: ( ^( 'Properties' (attrs+= attr )* ) -> main(attrs=$attrs))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:34:7: ^( 'Properties' (attrs+= attr )* )
            {
            match(input,7,FOLLOW_7_in_main86); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:34:27: (attrs+= attr )*
                loop1:
                do {
                    int alt1=2;
                    int LA1_0 = input.LA(1);

                    if ( (LA1_0==ATTRIBUTE) ) {
                        alt1=1;
                    }


                    switch (alt1) {
                	case 1 :
                	    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:34:27: attrs+= attr
                	    {
                	    pushFollow(FOLLOW_attr_in_main90);
                	    attrs=attr();

                	    state._fsp--;

                	    if (list_attrs==null) list_attrs=new ArrayList();
                	    list_attrs.add(attrs.getTemplate());


                	    }
                	    break;

                	default :
                	    break loop1;
                    }
                } while (true);


                match(input, Token.UP, null); 
            }


            // TEMPLATE REWRITE
            // 35:2: -> main(attrs=$attrs)
            {
                retval.st = templateLib.getInstanceOf("main",
              new STAttrMap().put("attrs", list_attrs));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "main"

    public static class attr_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "attr"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:37:1: attr : ^( ATTRIBUTE name= ID value= STRING ) -> attribute(name=$namevalue=$value);
    public final PropertiesTreeGrammar.attr_return attr() throws RecognitionException {
        PropertiesTreeGrammar.attr_return retval = new PropertiesTreeGrammar.attr_return();
        retval.start = input.LT(1);

        CommonTree name=null;
        CommonTree value=null;

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:37:5: ( ^( ATTRIBUTE name= ID value= STRING ) -> attribute(name=$namevalue=$value))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\PropertiesTreeGrammar.g:37:7: ^( ATTRIBUTE name= ID value= STRING )
            {
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_attr111); 

            match(input, Token.DOWN, null); 
            name=(CommonTree)match(input,ID,FOLLOW_ID_in_attr115); 
            value=(CommonTree)match(input,STRING,FOLLOW_STRING_in_attr119); 

            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 38:2: -> attribute(name=$namevalue=$value)
            {
                retval.st = templateLib.getInstanceOf("attribute",
              new STAttrMap().put("name", name).put("value", value));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "attr"

    // Delegated rules


 

    public static final BitSet FOLLOW_7_in_main86 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_attr_in_main90 = new BitSet(new long[]{0x0000000000000048L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_attr111 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_attr115 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_attr119 = new BitSet(new long[]{0x0000000000000008L});

}